package com.swingson.easydrag.graphics;

import java.awt.Component;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;

import javax.swing.JList;

/**
 * Dragged Image factory that retrieves dragged image data from a given
 * component.
 *
 * @author Mohamed Mansour
 */
public class DraggedImageFactory {

    /**
     * Retrieve dragged image data from a component.
     *
     * @param component The component to parse out dragged image data.
     * @return
     */
    public static DraggedImage getDraggedImage(Component component,
            boolean visible) {
        if (!visible) {
            return new DraggedImage() {
                @Override
                public boolean isDraggable() {
                    return false;
                }

                @Override
                public BufferedImage getImage() {
                    return null;
                }

                @Override
                public Rectangle getBounds() {
                    return null;
                }
            };
        }
        if (component instanceof JList) {
            return new DraggedImageJListImpl((JList) component);
        } else {
            return new DraggedImageJComponentImpl(component);
        }
    }
}
